# syntax=docker/dockerfile:1

# Build Stage
FROM golang:1.25-alpine AS build

WORKDIR /app

# Copy go.mod and go.sum and download dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy the rest of the application source code
COPY . .

# Build the application for production
# CGO_ENABLED=0 is important for creating a static binary
# -ldflags="-w -s" strips debug information and symbols to reduce binary size
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-w -s" -o /app/main ./cmd/server

# Final Stage
FROM scratch

# Copy the built binary from the build stage
COPY --from=build /app/main /main
COPY --from=build /app/configs/config.yml /configs/config.yml

# Expose the application port
EXPOSE 8080

# Command to run the application
CMD ["/main"]
